<template>
	<view>
		<Header title="营业执照" :showBack="true"></Header>
		<view class="container" v-if="list.length>0">
			<view class="box" v-if="list.length>0">
				<view>
					<block v-for="(item,index) in list" :key="index">
						<image v-if="item.type!=3" :src="baseUrl +'/file/api/uploadFile/downloadByKey?id='+ item.pictureId" mode="widthFix"></image>
						<view class="pdf-box" v-if="item.type == 3" @click="getImg(item.pictureId)">
							<image src="/static/PDF.png" mode=""></image>
						</view>
					</block>
					
				</view>
				<waterMarker col="2" :row="list.length*3" :text="organizationName" opacity="0.3" color="black" rotate="-30deg"></waterMarker>
			</view>
		</view>
	</view>
</template>

<script>
	import waterMarker from "@/components/sdq-watermarker/waterMarker.vue"
	export default {
		components:{ waterMarker },
		data() {
			return {
				baseUrl:getApp().globalData.baseUrl,
				tenantId: uni.getStorageSync('info').tenantId,
				organizationName: uni.getStorageSync('info').organizationName,
				list: [],
				curPage: 1,
				limit: 999,
				isQingqiu: false
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getImg(id){
				uni.downloadFile({
				  url: `${this.baseUrl}/file/api/uploadFile/downloadByKey?id=${id}`,
				  success: function (res) {
				    var filePath = res.tempFilePath;
				    uni.openDocument({
				      filePath: filePath,
				      showMenu: true,
				      success: function (res) {
				        console.log('打开文档成功');
				      }
				    });
				  }
				});
			},
			getList(){
				this.$http('/systemSetting/api/tenantPicture/list1',{
					condition:{
						startFileDate: '',
						endFileDate: '',
						tenantId: this.tenantId,
						// tenantId: '7b1e82b0-7ea5-4b00-b93b-08c1760ecd2e',
						typeFlag: 11
					},
					page: this.curPage,
					pageNum: this.curPage,
					pageSize: this.limit,
					rows: this.limit,
				},res=>{
					if (res.data.items.length > 0) {
						res.data.items.map(item=>{
							this.list.push({type: item.materialTypeFlag,pictureId: item.pictureId})
						})
					}
				})
			},
			
		}
	}
</script>

<style lang="less"  scoped>
.box{
	position: relative;
	width: 100%;
	background-color: #FFF;
	border-radius: 12upx;
	box-sizing: border-box;
	box-shadow: 0 3upx 20upx 1upx rgba(247, 200, 122, .2);
	>view{
		text-align: center;
		border-radius: 16upx;
		overflow: hidden;
		>view{
			width: 90%;
			margin: 0 auto;
			color: #666;
			font-size: 32upx;
			text-align: left;
			>text{
				color: red;
			}
		}
		>image{
			width: 648upx;
			vertical-align: middle;
		}
	}
}
.pdf-box{
	text-align: center!important;
	position: relative;
	z-index: 9999;
	image{
		width: 200rpx;
		height: 200rpx;
	}
}
</style>

